package com.ruoyi.lhky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.lhky.pojo.Tester;
import org.apache.ibatis.annotations.*;

@Mapper
public interface TesterMapper extends BaseMapper<Tester> {
    @Insert("INSERT INTO tester (name, hospitalization_number, department, ward, bad_number, hospital_id, group_id, random, crf) VALUES (#{name}, #{hospitalizationNumber}, #{department}, #{ward}, #{badNumber}, #{hospitalId}, #{groupId}, #{random}, #{crf})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertTester(Tester tester);

    @Insert("INSERT INTO research_tester (research_id, tester_id) VALUES (#{researchId}, #{testerId})")
    int insertResearchTester(@Param("researchId") Long researchId, @Param("testerId") Long testerId);

    @Update("UPDATE tester SET group_id = #{groupId} WHERE id = #{id}")
    int updateGroupId(@Param("id") Long id, @Param("groupId") Integer groupId);

    @Update("UPDATE tester SET random = #{random} WHERE id = #{id}")
    int updateRandom(@Param("id") Long id, @Param("random") String random);
}
